Skip to content

WARN: Only warn about inconsistent parsing if there are multiple non-null elements #52195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Mar 25, 2023

Not sure this needs a whatsnew note as it could just be considered part of the PDEP4 changes, which haven't yet reached user-facing status

The idea here is to only warn if there are at least 2 non-null elements - otherwise, a single element can't be inconsistently-parsed :)

@MarcoGorelli MarcoGorelli added Datetime Datetime data dtype Warnings Warnings that appear or should be added to pandas labels Mar 25, 2023
@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Mar 25, 2023
@MarcoGorelli MarcoGorelli force-pushed the only-warn-if-multiple-elements branch from 686a72e to 44d0e9f Compare March 25, 2023 08:24
@MarcoGorelli MarcoGorelli marked this pull request as ready for review March 25, 2023 09:41
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit otherwise lgtm

)
# If there are multiple non-null elements, warn about
# how parsing might not be consistent
if tslib.first_non_null(arr[first_non_null + 1 :]) != -1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor nit I'd have is to add an explicit if first_non_null == len(arr) check preceding this. It doesn't have any impact as long as this stays a purely Python function, but if someone tried to convert down to C I'm not sure how slicing beyond the length of the array would work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this. Thought this was a pyx file

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@mroeschke mroeschke merged commit a70a1f8 into pandas-dev:main Mar 27, 2023
@mroeschke
Copy link
Member

Thanks @MarcoGorelli

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Mar 27, 2023
MarcoGorelli added a commit that referenced this pull request Mar 27, 2023
…t parsing if there are multiple non-null elements) (#52242)

Backport PR #52195: WARN: Only warn about inconsistent parsing if there are multiple non-null elements

Co-authored-by: Marco Edward Gorelli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: inconsistant parsing between Timestamp and to_datetime
3 participants